{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}
{% import "_my_wtf_macros.html" as my_wtf_macros %}

{% block title %}万屏时代OPC--回应工程商列表{% endblock %}


{% block panel_heading %}
  万屏时代OPC--回应工程商列表
  <div class="pull-right btn-group">
      <a href="{{ url_for('op_bp.add_user') }}" class="btn btn-xs btn-success"
         style="margin-right: 5px;" target="_blank">
          新建用户
      </a>
  </div>
{% endblock %}


{% block panel_body %}
    <form id="search-call-order-form"
          action="{{ url_for('op_bp.sms_marketing_user', user_id=user.id) }}"
          method="post" class="form" role="form">
        <div class="well well-sm">
            {{ user.nickname }}
            <br/>
            {{ user.mobile | encrypt }}
        </div>
        {{ my_wtf_macros.form_field(form.sms_marketing_level, div_col=4, label_col=4, field_col=7) }}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        {{ my_wtf_macros.form_field(form.next_outbound, div_col=2, label_col=4, field_col=7) }}

        <!--下次回访-->
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div id="next_outbound_info">
            <div class="well well-sm">设置回访</div>
            {{ my_wtf_macros.form_field(form.next_outbound_schedule_time, div_col=4, label_col=4, field_col=7) }}
            {{ my_wtf_macros.form_field(form.next_outbound_call_reason, div_col=4, label_col=4, field_col=7) }}
            <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        </div>

        <!--计划外呼-->
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div id="outbound_record_info">
            <div class="well well-sm">计划外呼</div>
            <table id="schedule-outbound-records-table" class="table table-bordered table-hover table-condensed table-striped">
                {% if schedule_outbound_records%}
                   <thead>
                        <tr>
                            <th>计划外呼时间</th>
                            <th>外呼原因</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for r in schedule_outbound_records %}
                        <tr>
                            <td>{{ r.schedule_time_display }}</td>
                            <td>{{ r.call_reason_display }}</td>
                            <td>
                              <a
                                class="btn btn-xs btn-primary"
                                href="{{url_for('outbound_bp.cancel_outbound', record_id=r.id)}}"
                                name="cancel-outbound"
                              >取消外呼</a><br>
                          </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                {% else %}
                <tr><td>无</td></tr>
                {% endif %}
            </table>
        </div>
    

        <!--短信回应-->
        {% if sms_orders %}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div id="sms_orders_info">
            <div class="well well-sm">短信回应</div>

            <table id="sms-orders-table" class="table table-bordered table-hover table-condensed table-striped">
                <thead>
                    <tr>
                        <th>发送号码</th>
                        <th>发送时间</th>
                        <th>短信内容</th>
                    </tr>
                </thead>
                <tbody>
                    {% for r in sms_orders %}
                    <tr>
                        <td>{{ r.sender }}</td>
                        <td>{{ r.transfer_time }}</td>
                        <td>{{ r.sms_content }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% endif %}

        <!--电话回应-->
        {% if call_orders %}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div id="call_orders_info">
            <div class="well well-sm">电话回应</div>

            <table id="call-ordres-table" class="table table-bordered table-hover table-condensed table-striped">
                <thead>
                    <tr>
                        <th>主叫号码</th>
                        <th>主叫虚拟号</th>
                        <th>拨打时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for r in call_orders %}
                    <tr>
                        <td>{{ r.caller }}</td>
                        <td>{{ r.called_show }}</td>
                        <td>{{ r.begin_time }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% endif %}

        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        <div class="pull-right btn-group">
            <span>
                <button type="submit" class="btn btn-info"
                        id="query-user-btn">
                保存
            </button>
            </span>
        </div>
    </form>


{% endblock %}

{% block scripts %}
{{ super() }}

<script>
    $(document).ready( function () {
        // 设置回访联动
        var next_outbound_val = $('#next_outbound').is(':checked');
        if (next_outbound_val === true) {
            $('#next_outbound_info').show();
        } else {
            $('#next_outbound_info').hide();
        }
        $('#next_outbound').change(function () {
            var val = $(this).is(':checked');
            if (val === true) {
                $('#next_outbound_info').show();
            } else {
                $('#next_outbound_info').hide();
            }
        });
    })
</script>
{% endblock %}
